package com.es.hr.shopscore;

import java.lang.reflect.Field;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import com.es.business.area.AreaBean;
import com.es.business.area.AreaBiz;
import com.es.business.city.CityBean;
import com.es.business.city.CityBiz;
import com.es.business.citys.CitysBean;
import com.es.business.citys.CitysBiz;
import com.es.business.province.ProvinceBean;
import com.es.business.province.ProvinceBiz;
import com.es.hr.emp.EmpInfoBean;
import com.es.hr.shop.ShopBean;
import com.es.hr.shop.ShopBiz;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class ShopScoreSearchInitAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		ShopScoreBiz shopScoreBiz = new ShopScoreBiz();
		
		PageBean res = shopScoreBiz.searchShopScoreByTime("","", 1);
		
		for(int i = 0 ; i < res.getMap().size(); ++i){
			HashMap<String, Object> map = res.getMap().get(i);
			String shopId = map.get("shop_id").toString();
			ShopBean shop = new ShopBiz().getShopById(shopId);
			this.shopInfoBeanSet(map, shop);
		}
		this.request.setAttribute("pageBean", res);
		this.request.setAttribute("areaList", new AreaBiz().getAreaList());
		result = "success";
		return result;
	}
	
	private void shopInfoBeanSet(HashMap<String, Object> map, ShopBean bean) throws SecurityException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException{
		Field[] fds = Class.forName("com.es.hr.shop.ShopBean").getDeclaredFields();   
		
		for(int i=0;i<fds.length;i++){   
				map.put(fds[i].getName(), fds[i].get(bean));
		}
	}

}
